﻿using Inovout.Cloud.Models;
using Inovout.Cloud.Services;
using Inovout.Cloud.Storage.Models;
using Inovout.Cloud.Storage.Services;
using Inovout.Cloud.Web.Http;

namespace Inovout.Cloud.Storage.Web.Controllers
{
    public class StorageController : CloudHttpController
    {
        private IProjectService projectService;
        private IBucketService bucketService;
        public StorageController()
        {
            this.projectService = ComponentRegistry.Resolve<IProjectService>();
            this.bucketService = ComponentRegistry.Resolve<IBucketService>();
        }
        protected override void Initialize()
        {
            object projectName = null;
            if (base.TryGetParameterValue("project", out projectName))
            {
                base.Project = projectService.FindByName(projectName.ToString());
                if (base.Project == null)
                {
                    throw new System.Exception(string.Format("{0}项目不存在", projectName));
                }
            }

        }
    }
}